-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add -Zfix-edition
#15596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add -Zfix-edition
#15596
Conversation
08b0aa2
to
9617f3b
Compare
tests/testsuite/fix.rs
Outdated
[package] | ||
name = "foo" | ||
edition = "future" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't tell, is the trailing whitespace on this line intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's just an artifact of how the str!
macro works (which handles automatic updates). There isn't a blank line here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be the same answer, but just in case it was ambiguous, what stood out here wasn't the blank line, but that (unlike the blank lines above) the line contains 12 space characters (
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. Yea, that's a little awkward also due to defining inline. I went ahead and removed it.
This comment has been minimized.
This comment has been minimized.
This factors out the code to reload a workspace since I will be needing to reuse this elsewhere. There is some risk with this method not getting updated correctly in the future as new fields are added to Workspace (and it may be missing some things now), but that is an issue with the existing code.
This adds support for parsing the `-Zfix-edition` flag.
This adds the `EditionFixMode` enum to control the behavior of `cargo fix --edition`. The main intent is to provide a way to force `cargo fix` to migrate to a specific edition, instead of just going to the "next". This will be needed for `-Zfix-edition` in order to force it to use the "future" edition, which is never the "next" edition. This requires being able to serialize and deserialize this setting as it is conveyed through an environment variable to the recursive cargo invocation.
This adds the implementation for the behavior of `cargo fix -Zfix-edition`.
r? @weihanglo rustbot has assigned @weihanglo. Use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation looks reasonable with those tests. I didn't really follow closely enough to understand whether it fits edition testing's nees, but you know better than me so 👍🏾.
Feel free to merge it with or without addressing line breaking issue.
@@ -1915,6 +1916,19 @@ When new editions are introduced, the `unstable-editions` feature is required un | |||
|
|||
The special "future" edition is a home for new features that are under development, and is permanently unstable. The "future" edition also has no new behavior by itself. Each change in the future edition requires an opt-in such as a `#![feature(...)]` attribute. | |||
|
|||
## `fix-edition` | |||
|
|||
`-Zfix-edition` is a permanently unstable flag to assist with testing edition migrations, particularly with the use of crater. It only works with the `cargo fix` subcommand. It takes two different forms: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to have any line wrap here, or follow https://sembr.org/?
I am forgetting what the style we currently adopt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Reference and other documents we're just unwrapping now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. Thanks for the clarification. I'll merge as-is.
This adds a new
cargo fix -Zfix-edition
permanently unstable flag to assist with edition migration testing, particularly with crater.The commits and given documentation should explain how it works, but there will be forthcoming edition documentation (on the forge) once all the pieces with crater come together.